import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {getToken} from '@utils/auth';

@Injectable({
  providedIn: 'root',
})
export class HomeService {
  constructor(private $http: HttpClient) {
  }

  history_add_item(data: any): Observable<any> {
    const token = getToken();

    return this.$http.post('/api/history/add_item', data, {
      responseType: 'json',
      headers: {
        Authorization: `Bearer ${token}`,
      },
    });
  }

  history_clear(): Observable<any> {
    const token = getToken();

    return this.$http.post('/api/history/clear', null, {
      responseType: 'json',
      headers: {Authorization: `Bearer ${token}`},
    });
  }

  history_list(): Observable<any> {
    const token = getToken();

    return this.$http.get('/api/history/list', {
      responseType: 'json',
      headers: {Authorization: `Bearer ${token}`},
    });
  }
}
